﻿using System;
using System.Text;
//using System.Reflection;
namespace Notepad_X.Classes.Event
{
    /// <summary>
    /// Document event types
    /// </summary>
    public enum DocumentEvents { @New , Open , Close , Save, Other };

    public class DocumentEvent : EventArgs
    {
        private int DocId;
        private DocumentEvents DocEvent;

        /// <summary>
        /// The id of the Document
        /// </summary>
        public int DocumentId
        {
            get{return DocId;}
        }

        /// <summary>
        /// The event type
        /// </summary>
        public DocumentEvents Event
        {
            get{return DocEvent;}
        }

        /// <summary>
        /// Document Event Constructor
        /// </summary>
        /// <param name="DocumentId">The id of the document</param>
        /// <param name="Event">The event type</param>
        public DocumentEvent(int DocumentId , DocumentEvents Event)
        {
            DocId = DocumentId;
            DocEvent = Event;
        }
    }
    public static class  Events
    {
        public static System.EventHandler AddHandler(String action)
        {
            Main main = Notepad_X.Static.MainInstance;

            switch (action.ToLower())
            {
                case "new":
                    return new System.EventHandler(main.handler_new);
                case "open":
                    return new System.EventHandler(main.handler_open);
                case "openfolder":
                    return new System.EventHandler(main.handler_openFolder);
                case "save":
                    return new System.EventHandler(main.handler_save);
                case "saveas":
                    return new System.EventHandler(main.handler_saveAs);
                case "close":
                    return new System.EventHandler(main.handler_close);                    
                case "closeall":
                    return new System.EventHandler(main.handler_closeAll);
                case "closeothers":
                    return new System.EventHandler(main.handler_closeOthers);
                case "print":
                    return new System.EventHandler(main.handler_print);
                case "printpreview":
                    return new System.EventHandler(main.handler_printPreview);
                case "pagesetup":
                    return new System.EventHandler(main.handler_pageSetup);
                case "exit":
                    return new System.EventHandler(main.handler_exit); 
                case "undo":
                    return new System.EventHandler(main.handler_undo);                    
                case "redo":
                    return new System.EventHandler(main.handler_redo);                    
                case "cut":
                    return new System.EventHandler(main.handler_cut);                    
                case "copy":
                    return new System.EventHandler(main.handler_copy);                    
                case "paste":
                    return new System.EventHandler(main.handler_paste);                    
                case "selectall":
                    return new System.EventHandler(main.handler_selectAll);
                case "selectnext":
                    return new System.EventHandler(main.handler_selectNext);
                case "selectprevious":
                    return new System.EventHandler(main.handler_selectPrevious);   
                case "find":
                    return new System.EventHandler(main.handler_find);
                case "replace":
                    return new System.EventHandler(main.handler_replace);
                case "goto":
                    return new System.EventHandler(main.handler_goto);
                case "next":
                    return new System.EventHandler(main.handler_selectNext);
                case "previous":
                    return new System.EventHandler(main.handler_selectPrevious); 
                case "rename":
                    return new System.EventHandler(main.handler_rename);                    
                case "options":
                    return new System.EventHandler(main.handler_options);                    
                case "favourite":
                    return new System.EventHandler(main.handler_favourite);
                case "favouritesorganize":
                    return new System.EventHandler(main.handler_favouritesOrganize);
                case "linenumbers":
                    return new System.EventHandler(main.handler_lineNumbers);
                case "about":
                    return new System.EventHandler(main.handler_about);                    
                case "website":
                    return new System.EventHandler(main.handler_website);                    
                case "bugreport":
                    return new System.EventHandler(main.handler_bugreport);                    
                case "featurerequest":
                    return new System.EventHandler(main.handler_featurerequest); 
                case "help":
                    return new System.EventHandler(main.handler_help);  
                default:
                    return null;
            }
        }
        //public static string InvokeStringMethod(string typeName, string methodName, string stringParam)
        //{
        //    // Get the Type for the class
        //    Type calledType = Type.GetType(typeName);

        //    // Invoke the method itself. The string returned by the method winds up in s.
        //    // Note that stringParam is passed via the last parameter of InvokeMember,
        //    // as an array of Objects.
        //    String s = (String)calledType.InvokeMember(
        //                    methodName,
        //                    BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static,
        //                    null,
        //                    null,
        //                    new Object[] { stringParam });

        //    // Return the string that was returned by the called method.
        //    return s;
        //}

    }


}
